package com.bw.hongye.other.controller;

import com.aliyun.common.utils.PageUtils;
import com.aliyun.common.utils.R;
import com.bw.hongye.other.entity.AttentionEntity;
import com.bw.hongye.other.service.AttentionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;




/**
 * 
 *
 * @author tZhe
 * @email tZhe@hongye.com
 * @date 2021-07-16 21:54:41
 */
@RestController
@RequestMapping("other/attention")
public class AttentionController {
    @Autowired
    private AttentionService attentionService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = attentionService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{attentionId}")
    public R info(@PathVariable("attentionId") Long attentionId){
		AttentionEntity attention = attentionService.getById(attentionId);

        return R.ok().put("attention", attention);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody AttentionEntity attention){
		attentionService.save(attention);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody AttentionEntity attention){
		attentionService.updateById(attention);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] attentionIds){
		attentionService.removeByIds(Arrays.asList(attentionIds));

        return R.ok();
    }

}
